import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DoRemoteImpl extends UnicastRemoteObject implements IDoRemote { 
  
    protected DoRemoteImpl() throws RemoteException { 
        super(); 
    } 
 
    private static final long serialVersionUID = -8158779541912069375L; 
 
    
    public int getServerTime() throws RemoteException { 
        return Integer.parseInt(new SimpleDateFormat("yyyyMMdd").format(new Date())); 
        // return new Date(); 
    } 
    public static void main(String[] args) throws MalformedURLException, RemoteException, NotBoundException { 
        try { 
            LocateRegistry.createRegistry(8808); 
            DoRemoteImpl Server = new DoRemoteImpl(); 
            Naming.rebind("//localhost:8808/Date-Server", Server); 
        } catch (java.net.MalformedURLException me) { 
            System.out.println("Malformed URL: " + me.toString()); 
        } catch (RemoteException re) { 
            System.out.println("Remote exception: " + re.toString()); 
        }
        String url = "//localhost:8808/Date-Server"; 
        IDoRemote RmiObject = (IDoRemote) Naming.lookup(url); 
        System.out.println(" Server Date: " + RmiObject.getServerTime()); 

}
   
}